import random
import time

from ttzScrapyProject.utils import MumberUtils
from ttzScrapyProject.utils.DateUtils import getDate
from ttzScrapyProject.vo.LoginUserVo import UserVo


def initNumMap():
    return {0: "N0",
            1: "N1",
            2: "N2",
            3: "N3",
            4: "N4",
            5: "N5",
            6: "N6",
            7: "N7",
            8: "N8",
            9: "N9",
            10: "N10",
            11: "N11",
            12: "N12",
            13: "N13",
            14: "N14",
            15: "N15",
            16: "N16",
            17: "N17",
            18: "N18",
            19: "N19",
            20: "N20",
            21: "N21",
            22: "N22",
            23: "N23",
            24: "N24",
            25: "N25",
            26: "N26",
            27: "N27"}


def convertNumString(num):
    numMap = initNumMap();
    return numMap.get(int(num))


"""
校验是否为null
"""
def isNonNull(str):
    if len(str):
        return False
    return True

def getNoticeText(loginUserVo,dateStr,str1):
    if type(loginUserVo.snowballtarget) == int:
        targetStr = str(loginUserVo.snowballtarget/10000)+"w"
        winAmountStr = str(loginUserVo.winAmount/10000)+"w"
    else:
        targetStr = str(loginUserVo.snowballtarget)
        winAmountStr = str(loginUserVo.winAmount)

    startStr = dateStr + "-" + str(loginUserVo.phone) + "-" + targetStr + "-" + winAmountStr + "-" + str(
        loginUserVo.model) + "-" + str1
    return startStr

def notConstrainModel(loginUserVo):
    if loginUserVo.model.find("N")!= -1:
        if MumberUtils.strToInt(loginUserVo.LuckNum) % MumberUtils.strToInt(loginUserVo.model[0:1]) != MumberUtils.strToInt(loginUserVo.model[-1]):
            return True
    else:
        # firstResult = re.sub(r'\-\d{1,}', 'N', loginUserVo.model)
        # modelData = ModelUtils.getXZModelData(firstResult, loginUserVo.model, result)[
        #         :MumberUtils.strToInt(loginUserVo.snowballCount) + 1]
        groupName = MumberUtils.strToInt(loginUserVo.model[0:2])
        groupValue = MumberUtils.strToInt(loginUserVo.model[-1])
        list_13_0 = [0,2,4,6,8,10,12]
        list_13_1 = [1,3,5,7,9,11,13]
        list_14_0 = [14,16,18,20,22,24,26]
        list_14_1 = [15,17,19,21,23,25,27]

        if groupName == 13 and groupValue == 0:
            if MumberUtils.strToInt(loginUserVo.LuckNum) not in list_13_0:
                return True
            else:
                return False
        if groupName == 13 and groupValue == 1:
            if MumberUtils.strToInt(loginUserVo.LuckNum) not in list_13_1:
                return True
            else:
                return False
        if groupName == 14 and groupValue == 0:
            if MumberUtils.strToInt(loginUserVo.LuckNum) not in list_14_0:
                return True
            else:
                return False
        if groupName == 14 and groupValue == 1:
            if MumberUtils.strToInt(loginUserVo.LuckNum) not in list_14_1:
                return True
            else:
                return False
    return False
if __name__ == '__main__':
    # snowballtarget="10000"
    # print(str(snowballtarget)+"-")
    # 生成一个[1, 10]范围内的随机整数
    print(random.randint(1, 10))
    print(random.randint(10, 30))
    vo = UserVo()
    vo.model="13-0"
    vo.LuckNum="12"
    print(notConstrainModel(vo))
    vo.LuckNum = "14"
    print(notConstrainModel(vo))
    vo.LuckNum ="15"
    print(notConstrainModel(vo))
    vo.LuckNum ="13"
    print(notConstrainModel(vo))
